/**
 * @param {number} mainTank
 * @param {number} additionalTank
 * @return {number}
 */
var distanceTraveled = function(mainTank, additionalTank) {
    if(mainTank < 5) return mainTank * 10
    let res = 0
    while(mainTank > 5) {
        mainTank -= 5
        res += 50
        if(additionalTank > 1) {
            mainTank += 1
            additionalTank -= 1
        }
    }
    return res
};
